<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" width="80%" destroy-on-close @closed="$emit('closed')" align-center>
        <el-container>
            <el-main>
                <el-form :model="form" :rules="rules" :disabled="mode == 'show'" ref="dialogForm" label-width="110px" label-position="right" style="height:650px;overflow:auto">
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="生产单号" prop="produce_no">
                                <el-input v-model="form.produce_no" placeholder="请输入生产单号"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="订单号" prop="order_no" >
                                <el-input v-model="form.order_no" placeholder="请出入订单号" readonly></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="工厂货号" prop="factory_number">
                                <el-input v-model="form.factory_number" placeholder="请输入工厂货号" readonly></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="批次号" prop="batch_number">
                                <el-input v-model="form.batch_number" placeholder="请输入批次号" readonly></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="skc" prop="skc" >
                                <el-input v-model="form.skc" placeholder="请输入skc" readonly></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="商品款式" prop="style_id">
                                <el-select v-model="form.style_id" clearable style="width: 100%" placeholder="请选择" disabled>
                                    <el-option v-for="item in goodsList" :key="item.id" :label="item.title" :value="item.id" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="客户交期" prop="deliver_time" >
                                <el-date-picker v-model="form.deliver_time" :value-format="'YYYY-MM-DD'" style="width:100%" type="date" placeholder="请选择交期时间" disabled />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="客户名称" prop="client_id" >
                                <el-select v-model="form.client_id" clearable style="width: 100%" filterable placeholder="请选择" disabled>
                                    <el-option v-for="item in curList" :key="item.custom_id" :label="item.apply_name" :value="item.custom_id" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="针种" prop="needle_seed">
                                <el-select v-model="form.needle_seed" clearable style="width: 100%" filterable placeholder="请选择">
                                    <el-option v-for="item in needleList" :key="item.id" :label="item.title" :value="item.id" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="8">
                            <el-form-item label="毛种" prop="wool_seed">
                                <el-select v-model="form.wool_seed" clearable style="width: 100%" placeholder="请选择">
                                    <el-option v-for="item in woolList" :key="item.id" :label="item.cate_name" :value="item.id" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="本厂大货跟单" prop="follow_id" >
                                <!-- <el-input v-model="form.follow_id" placeholder="请输入本厂大货跟单"></el-input> -->
                                <el-select v-model="form.follow_id" clearable style="width: 100%" placeholder="请选择">
                                    <el-option v-for="item in humList" :key="item.id" :label="item.name" :value="item.id" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="备注" prop="remark">
                                <el-input v-model="form.remark" placeholder="请输入备注"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- 订单明细 -->
                    <el-col :span="24">
                        <el-form-item label="订单明细" prop="size_data">
                            <sc-form-table ref="table" v-model="form.size_data" :addTemplate="addTemplate" placeholder="暂无数据" hideAdd hideDelete>
                                <el-table-column prop="size" label="尺码" width="180"></el-table-column>
                                <el-table-column prop="num" label="数量" min-width="180"></el-table-column>
                                <el-table-column prop="produce_num" label="计划生产数" min-width="180">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.produce_num" @input="input(scope.row)" placeholder="请输入计划生产数"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="weight" label="生产克重/G" min-width="180">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.weight"  @input="input(scope.row)" placeholder="请输入生产克重"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="total_weight" label="生产总重量/KG" min-width="180">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.total_weight" readonly placeholder="请输入生产总重量"></el-input>
                                    </template>
                                </el-table-column>
                            </sc-form-table>
                        </el-form-item>
                    </el-col>
                    <!-- 毛料 -->
                    <el-col :span="24">
                        <el-form-item label="毛料" prop="material_data">
                            <el-button type="primary" size="small" icon="el-icon-plus" @click="openWu">新增毛料</el-button>
                            <sc-form-table ref="table" v-model="form.material_data" :addTemplate="material" placeholder="暂无数据" hideAdd>
                                <!-- <el-table-column width="65">
                                    <template #default="scope">
                                        <el-button type="primary" size="small" icon="el-icon-search" @click="openWu(scope.row,scope.$index)"></el-button>
                                    </template>
                                </el-table-column> -->
                                <el-table-column prop="material_spec_code" label="物料编码" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.material_spec_code}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="material_name" label="物料名称" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.material_name}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="color_number" label="色号" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.color_number}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="colour" label="颜色" align="center">
                                    <template #default="scope">
                                        <div v-if="scope.row.colour">{{scope.row.colour}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="image" label="图片" align="center">
                                    <template #default="scope">
                                        <el-image style="width:50px;height:50px" :src="scope.row.image" :preview-src-list="scope.row.image" :initial-index="0" fit="cover" preview-teleported="true" />
                                    </template>
                                </el-table-column>
                                <el-table-column prop="apply_name" label="供应商" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.apply_name}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="ratio" label="比例" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.ratio" placeholder="请输入比例"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="loss_ratio" label="损耗比" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.loss_ratio" placeholder="请输入损耗比"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="loss_ratio" label="所需总重量" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.loss_ratio" placeholder="请输入所需总重量"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="remark" label="备注" align="center">
                                    <template #default="scope">
                                        <!-- <div v-if="scope.row.remark">{{scope.row.remark}}</div> -->
                                        <el-input v-model="scope.row.remark" placeholder="请输入备注"></el-input>
                                    </template>
                                </el-table-column>
                            </sc-form-table>
                        </el-form-item>
                    </el-col>
                    <!-- 工序 -->
                    <el-col :span="24">
                        <el-form-item label="工序信息" prop="process_data">
                            <sc-form-table ref="table" v-model="form.process_data" :addTemplate="process" placeholder="暂无数据">
                                <el-table-column width="65">
                                    <template #default="scope">
                                        <el-button type="primary" size="small" icon="el-icon-search" @click="openGong(scope.row,scope.$index)"></el-button>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="process_id" label="一级工序" align="center">
                                    <template #default="scope">
                                        <el-select v-model="scope.row.process_id" @change="changeGong(scope.row)" placeholder="请选择">
                                            <el-option v-for="item in processList" :key="item.id" :label="item.title" :value="item.id"></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="GongxuSon" label="二级工序" align="center">
                                    <template #default="scope">
                                        <el-select v-model="scope.row.two_process_id" placeholder="请选择">
                                            <el-option v-for="item in scope.row.GongxuSon" :key="item.id" :label="item.title" :value="item.id"></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="price" label="工序单价" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.price" placeholder="请输入工序单价"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="staff_id" label="选择员工" align="center">
                                    <template #default="scope">
                                        <el-select v-model="scope.row.staff_id" placeholder="请选择">
                                            <el-option v-for="item in humList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                                        </el-select>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="sort" label="排序" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.sort"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="remark" label="工序备注" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.remark"></el-input>
                                    </template>
                                </el-table-column>
                            </sc-form-table>
                        </el-form-item>
                    </el-col>
                    <!-- 辅料 -->
                    <el-col :span="24">
                        <el-form-item label="辅料" prop="accessories_data">
                            <el-button type="primary" size="small" icon="el-icon-plus" @click="openWuFu">新增辅料</el-button>
                            <sc-form-table ref="table" v-model="form.accessories_data" :addTemplate="material" placeholder="暂无数据" hideAdd>
                                <!-- <el-table-column width="65">
                                    <template #default="scope">
                                        <el-button type="primary" size="small" icon="el-icon-search" @click="openWuFu(scope.row,scope.$index)"></el-button>
                                    </template>
                                </el-table-column> -->
                                <el-table-column prop="material_spec_code" label="物料编码" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.material_spec_code}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="material_name" label="物料名称" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.material_name}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="color_number" label="色号" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.color_number}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="colour" label="颜色" align="center">
                                    <template #default="scope">
                                        <div v-if="scope.row.colour">{{scope.row.colour}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="image" label="图片" align="center">
                                    <template #default="scope">
                                        <el-image style="width:50px;height:50px" :src="scope.row.image" :preview-src-list="scope.row.image" :initial-index="0" fit="cover" preview-teleported="true" />
                                    </template>
                                </el-table-column>
                                <el-table-column prop="apply_name" label="供应商" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.apply_name}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="ratio" label="比例" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.ratio" placeholder="请输入比例"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="loss_ratio" label="损耗比" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.loss_ratio" placeholder="请输入损耗比"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="loss_ratio" label="所需总重量" align="center">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.loss_ratio" placeholder="请输入所需总重量"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="remark" label="备注">
                                    <template #default="scope">
                                        <el-input v-model="scope.row.remark" placeholder="请输入备注"></el-input>
                                    </template>
                                </el-table-column>
                            </sc-form-table>
                        </el-form-item>
                    </el-col>
                    <!-- 尺寸 -->
                    <el-col :span="24">
                        <el-form-item label="尺寸信息" prop="size">
                            <sc-form-table ref="table" v-model="size" :addTemplate="location" placeholder="暂无数据" hideAdd hideDelete>
                                <el-table-column prop="location_id" label="部位" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.location_name}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="size_latitude" label="尺寸纬度" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.size_latitude}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="measure_method" label="量法" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.measure_method}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="yangyi_size" label="样衣尺寸" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.yangyi_size}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="zhiyang_size" label="纸样尺寸" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.zhiyang_size}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="tiaoma" label="跳码" align="center" width="150">
                                    <template #default="scope">
                                        <div>{{scope.row.tiaoma}}</div>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="dahuo_size" label="大货尺寸" align="center">
                                    <el-table-column align="center" v-for="(child,index) in location.dahuo_size" :key="index" :label="child.size_name" :prop="child.size">
                                        <template #default="scope">
                                            <div>{{scope.row.dahuo_size[index].size}}</div>
                                        </template>
                                    </el-table-column>
                                </el-table-column>
                                <el-table-column prop="tolerance_range" label="允差范围" align="center">
                                    <template #default="scope">
                                        <div>{{scope.row.tolerance_range}}</div>
                                    </template>
                                </el-table-column>
                            </sc-form-table>
                        </el-form-item>
                    </el-col>
                    <el-row :gutter="1">
                        <el-col :span="8">
                            <el-form-item label="吓数文件">
                                <sc-upload-file v-model="form.paper_sample_url" :limit="3" disabled>
                                    <el-button type="primary" icon="el-icon-upload" @click="paperUpload">吓数文件下载</el-button>
                                </sc-upload-file>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="画花文件">
                                <sc-upload-file v-model="form.ziliao_url" :limit="3" disabled>
                                    <el-button type="primary" icon="el-icon-upload" @click="ziliaoUpload">画花文件下载</el-button>
                                </sc-upload-file>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </el-main>
            <el-footer>
                <div style="display:flex;justify-content: end;">
                    <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">保存并审核</el-button>
                    <el-button :loading="isSaveing" @click="submit()">保存</el-button>
                    <el-button @click="visible=false" >取消</el-button>
                </div>
            </el-footer>
        </el-container>
        <wu v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false" draggable></wu>
        <gong v-if="dialog.gong" ref="gongDialog" @success="gongSuccess" @closed="dialog.gong = false" draggable></gong>
	</el-dialog>
</template>

<script>
import Gong from './gong'
import wu from './wu'
	export default {
        components: { wu,Gong },
		emits: ['success', 'closed'],
		data() {
			return {
				mode: "add",
				titleMap: {
					add: '完善生产单',
					edit: '编辑生产单',
					show: '查看'
				},
                dialog: {
				    save: false,
                    gong:false
			    },
				visible: false,
				isSaveing: false,
                grade:"潜力",
				//表单数据
				form: {
					id:"",
					produce_no: "",
                    order_no: "",
                    factory_number: "",
                    batch_number: "",
                    skc: "",
                    style_id: "",
                    deliver_time: "",
                    client_id: "",
                    needle_seed:"",
                    wool_seed:"",
                    follow_id:"",
                    remark:"",
                    size_data:[],   //订单明细
                    material_data:[],   //毛料使用配比
                    accessories_data:[],   //辅料配比
                    process_data:[],   //工序
                    paper_sample_url:"",
                    ziliao_url:"",
				},
                size:[],
                material:{material_code:"",material_id:"",},
                process:{process_id:"",two_process_id:"",sort:"",price:"",remark:"",staff_id:""},
                location:{location_id:"",size_latitude:"",measure_method:"",yangyi_size:"",zhiyang_size:"",tiaoma:"",tolerance_range:"",dahuo_size:[]},
				//验证规则
				rules: {
				},
				goodsList: [],  //商品款式
                curList:[],//客户
                needleList:[],//针种
                woolList:[],//毛种
                humList:[],//员工
			}
		},
		mounted() {
            this.getAllGoodsStyle()
            this.getCustomerList()
            this.getNeedle()
            this.getWool()
            this.getHum()
            this.getProcess()
		},
		methods: {
             paperUpload() {
                // 下载文件
                const fileUrl = this.form.paper_sample_url;
                const link = document.createElement("a");
                link.href = fileUrl;
                link.download = this.form.paper_sample_url;
                link.click();
            },
            ziliaoUpload() {
                // 下载文件
                const fileUrl = this.form.ziliao_url;
                const link = document.createElement("a");
                link.href = fileUrl;
                link.download = this.form.ziliao_url;
                link.click();
            },
			//显示
			open(mode='add'){
				this.mode = mode;
				this.visible = true;
				return this
			},
			//表单提交方法
			submit(){
				this.$refs.dialogForm.validate(async (valid) => {
					if (valid) {
						this.isSaveing = true;
						var res  = [];
                        if(this.mode=="edit"){
                            res = await this.$API.produce.getProduce.perfect.edit(this.form);
                        }else{
                            res = await this.$API.produce.getProduce.perfect.post(this.form);
                        }
						this.isSaveing = false;
						if(res.code == 1){
							this.$emit('success', this.form, this.mode)
							this.visible = false;
							this.$message.success("操作成功")
						}else{
							this.$alert(res.message, "提示", {type: 'error'})
						}
					}else{
						return false;
					}
				})
			},
			//表单注入数据
			async setData(data){
                console.log('data :>> ', data);
                this.form.id = data.id
                var res = await this.$API.produce.getProduce.detail.get({id:data.id});
                this.form.produce_no = res.data.produce_no
                this.form.order_no = res.data.order_no
                this.form.factory_number = res.data.factory_number
                this.form.batch_number = res.data.batch_number
                this.form.skc = res.data.skc
                this.form.style_id = res.data.style_id
                this.form.deliver_time = res.data.deliver_time
                this.form.client_id = res.data.client_id
                this.form.needle_seed = res.data.needle_seed
                this.form.wool_seed = res.data.wool_seed
                this.form.follow_id = res.data.follow_id
                this.form.remark = res.data.remark
                this.form.paper_sample_url = res.data.goods.paper_sample_url
                this.form.ziliao_url = res.data.goods.ziliao_url
                // 尺寸
                // let size = []
                this.size = res.data.goodsSpec
                    res.data.goodsSpec.map(item=>{
                        let a = item.dahuo_size
                        this.location.dahuo_size = a
                    })
                // 订单明细size_data
                let orderDetail = []
                res.data.orderDetail.map(item=>{
                    orderDetail.push({
                        id:item.id,
                        size:item.goods_size,
                        num:item.num,
                        produce_num:item.produce_num,
                        weight:item.weight,
                        total_weight:item.total_weight
                    })
                })
                this.form.size_data = orderDetail
                // 辅料
                let accessData = []
                res.data.accessories_data.map(item=>{
                    accessData.push({
                        id:item.id,
                        material_spec_code:item.material_spec_code,
                        ratio:item.ratio,
                        loss_ratio:item.loss_ratio,
                        remark:item.remark,
                        material_name:item.material_name,
                        color_number:item.materialSpec.color_number,
                        colour:item.materialSpec.colour,
                        image:item.materialSpec.image,
                        apply_name:item.materialSpec.apply_name,
                    })
                })
                this.form.accessories_data = accessData
                // 毛料
                let materialData = []
                res.data.material_data.map(item=>{
                    materialData.push({
                        id:item.id,
                        material_spec_code:item.material_spec_code,
                        ratio:item.ratio,
                        loss_ratio:item.loss_ratio,
                        remark:item.remark,
                        material_name:item.material_name,
                        color_number:item.materialSpec.color_number,
                        colour:item.materialSpec.colour,
                        image:item.materialSpec.image,
                        apply_name:item.materialSpec.apply_name,
                    })
                })
                this.form.material_data = materialData
                // 工序
                let processData = []
                res.data.process.map(item=>{
                    processData.push({
                        id:item.id,
                        process_id:item.process_id,
                        two_process_id:item.two_process_id,
                        sort:item.sort,
                        price:item.price,
                        staff_id:item.staff_id,
                        remark:item.remark,
                        GongxuSon:item.GongxuSon
                    })
                })
                this.form.process_data = processData
			},
            // 获取款式
            async getAllGoodsStyle(){
				var res = await this.$API.goods.getAllGoodsStyle.get();
				this.goodsList = res.data;
			},
            // 获取客户
            async getCustomerList(){
				var res = await this.$API.all.customer.get();
				this.curList = res.data;
			},
            //所有针种
            async getNeedle(){
                var res = await this.$API.all.needle.get();
                this.needleList = res.data;
            },
            // 毛种
            async getWool(){
                var res = await this.$API.basic.apply.getInfo.get({pid:1});
                this.woolList = res.data;
            },
            // 跟单人
            async getHum(){
                var res = await this.$API.all.staff.get();
                this.humList = res.data;
            },
            // 所有工序
            async getProcess(){
                var res = await this.$API.all.process.get({pid:0});
                this.processList = res.data;
            },
            // 二级工序
            async changeGong(e){
                var res = await this.$API.all.process.get({pid:e.process_id});
                e.GongxuSon = res.data
            },
            // 毛料
            openWu(row){
                console.log('row :>> ', row);
                this.dialog.save = true
                this.$nextTick(() => {
                    this.$refs.saveDialog.open('add').setData({type:1})
                })
            },
            // 辅料
            openWuFu(row){
                console.log('row :>> ', row);
                this.dialog.save = true
                this.$nextTick(() => {
                    this.$refs.saveDialog.open('add').setData({type:2})
                })
            },
            handleSuccess(data, mode) {
                console.log('mode :>> ', mode)
                let a = []
                data.map((item)=>{
                    a.push({
                        material_id:item.material.material_id,
                        material_spec_code:item.spec_code,
                        category_name:item.material.category_name,
                        material_name:item.material.material_name,
                        color_number:item.color_number,
                        colour:item.colour,
                        image:item.image,
                        apply_name:item.material.apply_name,
                        remark:item.remark,
                    })
                })
                let existingIds = this.form.material_data.map(item => item.material_spec_code);
                for(let i = a.length - 1; i >= 0; i--){
                    if(existingIds.includes(a[i].material_spec_code)){
                        a.splice(i, 1);
                    }
                }
                let existingIds1 = this.form.accessories_data.map(item => item.material_spec_code);
                for(let i = a.length - 1; i >= 0; i--){
                    if(existingIds1.includes(a[i].material_spec_code)){
                        a.splice(i, 1);
                    }
                }
                if(mode==1){
                    this.form.material_data = [...this.form.material_data,...a]
                }else{
                    this.form.accessories_data = [...this.form.accessories_data,...a]
                }
            },
            openGong(row,index){
                this.dialog.gong = true
                this.$nextTick(() => {
                    this.$refs.gongDialog.open('add').setData({index:index})
                })
            },
            gongSuccess(data, mode) {
                console.log('mode :>> ', mode);
                this.form.process_data = []
                data[0].detail.map(item=>{
                    this.form.process_data.push({
                        process_id:item.process_id,
                        process_title:item.process_title,
                        price:item.price,
                        sort:item.sort,
                        remark:item.remark,
                        GongxuSon:item.GongxuSon,
                        staff_id:"",
                        two_process_id:item.two_process_id
                    })
                })
            },
            input(row){
                console.log('row :>> ', row);
                if (row.produce_num.charAt(0) === "0") {
                    row.produce_num = row.produce_num.slice(1);
                }
                if (row.weight.charAt(0) === "0") {
                    row.weight = row.weight.slice(1);
                }
                row.total_weight = Number(row.produce_num) * Number(row.weight);
            }
		}
	}
</script>

<style lang="scss"></style>
